import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'limitDetailTableNewM',
  state: {},
  effects: {
    //获取报表详情数据
    *queryReportInfoById({ payload, callback }, { call, put }) {
      const response = yield call(api.limitThroughReportNew.queryReportTable, payload);
      if (response && response.code == 0) {
        callback(response.data);
      } else {
        callback({});
        message.error(response?.msg || '查询报表详情失败!');
      }
    },

    //获取详情数据
    *getDetails({ payload, callback }, { call, put }) {
      const response = yield call(api.limitAlarmquery.getLimitDetail, payload);
      if (response && response.code == 0) {
        callback(response);
      } else if (response) {
        callback({});
        message.error(response.message || '查询限额详情失败!');
      } else {
        callback({});
        message.error('查询限额详情失败!');
      }
    },

    //获取触警详情数据
    *getWarningDetails({ payload, callback }, { call, put }) {
      const response = yield call(api.limitAlarmquery.getLimitWariningDetail, payload);
      if (response && response.code == 0) {
        callback(response);
      } else if (response) {
        callback({});
        message.error(response.message || '查询限额详情失败!');
      } else {
        callback({});
        message.error('查询限额详情失败!');
      }
    },
  },
  reducers: {
    setState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
